***********************************
* Do File for "Spying from Space" *
* Journal of Conflict Resolution  *	
* By Bryan Early and Erik Gartzke *
* Version January 27,2020		  *
***********************************

/* Replicating the tables requires the installation of the STATA estout package. 
*/

***************************************
* Analysis for the in-text discussion * 
***************************************

*Identifying MIDs with Surveillance Satellite Cases Using DV with Fatality Level 3-6 (100+ Total Battle Deaths in a Year)**

count if yrSalientMIDs_SA==1 & PolRev==1

count if yrSalientMIDs_SA==1 & NoServSat ==1 & PolRev==1
count if yrSalientMIDs_SA==1 & Only1ServSat ==1 & PolRev==1
count if yrSalientMIDs_SA==1 & Only2ServSat ==1 & PolRev==1
count if yrSalientMIDs_SA==1 & BothServSat ==1 & PolRev==1

**Counting and Listing Cases**

count if yrSalientMIDs_SA==1 & ServSat1 ==1 & PolRev==1
count if yrSalientMIDs_SA==1 & ServSat2 ==1 & PolRev==1

list ddyad year if yrSalientMIDs_SA==1 & ServSat1 ==1 & PolRev==1
list ddyad year if yrSalientMIDs_SA==1 & ServSat2 ==1 & PolRev==1

**Identifying MIDs with Surveillance Satellite Cases Using DV with Fatality Level 2-6 (25+ Total Battle Deaths in a Year)**

count if yrSalientMIDs_SA2==1 & NoServSat ==1 & PolRev==1
count if yrSalientMIDs_SA2==1 & Only1ServSat ==1 & PolRev==1
count if yrSalientMIDs_SA2==1 & Only2ServSat ==1 & PolRev==1
count if yrSalientMIDs_SA2==1 & BothServSat ==1 & PolRev==1

count if yrSalientMIDs_SA2==1 & ServSat1 ==1 & PolRev==1
count if yrSalientMIDs_SA2==1 & ServSat2 ==1 & PolRev==1

list ddyad year if yrSalientMIDs_SA2==1 & ServSat1 ==1 & PolRev==1
list ddyad year if yrSalientMIDs_SA2==1 & ServSat2 ==1 & PolRev==1

**Cross Tab: Both States Have Surveillance Satellites and Serious Conflict**
tab yrSalientMIDs_SA BothServSat if PolRev==1 , col



*******************************************
* Replication for Tables 1-3 and Figure 1 * 
*******************************************

*** Replication for Table 1**
tab yrSalientMIDs_SA ServSat1 if HadSalMIDEver==1 & PolRev==1, chi col
tab yrSalientMIDs_SA ServSat2 if HadSalMIDEver==1 & PolRev==1, chi col


***Replication for Table 2***
**All Periods - All Side A States: DV is a MID year observation occurs with fatalities of more than 100**
eststo M1: relogit  yrSalientMIDs_SA ServSat1 ServSat2 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000
eststo M2: relogit 	yrSalientMIDs_SA ServSat1 ServSat2  		lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000
eststo M3: relogit  yrSalientMIDs_SA ServSat1 ServSat2 post2000 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1  
eststo M4: relogit 	yrSalientMIDs_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1


esttab M1 M2 M3 M4, se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01)

**Figure 1: Coefficient Plot**

relogit 	yrSalientMIDs_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1
coefplot, drop (lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb _cons) xline(0)


**Replication for Table 3: Predicted Probabilities and Relative Risks using Model 4**

relogit 	yrSalientMIDs_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1
setx mean
 
 setx ServSat1 0 ServSat2 0 post2000 0 Dem1 0 Dem2 0 Dem_Both 0 defense 0 Strat_Riv 0 yrSalientNoMIDs_SA 16 yrSalientNoMIDs_SA_sq 256 yrSalientNoMIDs_SA_cb 4096
 relogitq 
 
 setx ServSat1 1 ServSat2 0 post2000 0 Dem1 0 Dem2 0 Dem_Both 0 defense 0 Strat_Riv 0 yrSalientNoMIDs_SA 16 yrSalientNoMIDs_SA_sq 256 yrSalientNoMIDs_SA_cb 4096
 relogitq
 
 setx ServSat1 0 ServSat2 1 post2000 0 Dem1 0 Dem2 0 Dem_Both 0 defense 0 Strat_Riv 0 yrSalientNoMIDs_SA 16 yrSalientNoMIDs_SA_sq 256 yrSalientNoMIDs_SA_cb 4096
 relogitq
 
 setx ServSat1 1 ServSat2 1 post2000 0 Dem1 0 Dem2 0 Dem_Both 0 defense 0 Strat_Riv 0 yrSalientNoMIDs_SA 16 yrSalientNoMIDs_SA_sq 256 yrSalientNoMIDs_SA_cb 4096
 relogitq
 
 
 setx ServSat1 0 ServSat2 0 post2000 0 Dem1 0 Dem2 0 Dem_Both 0 defense 0 Strat_Riv 0 yrSalientNoMIDs_SA 16 yrSalientNoMIDs_SA_sq 256 yrSalientNoMIDs_SA_cb 4096
 relogitq, rr(ServSat1 0 1)
 relogitq, rr(ServSat2 0 1)
 relogitq, rr(ServSat1 0 1 ServSat2 0 1)
 
 
  setx ServSat1 0 ServSat2 0 post2000 0 Dem1 0 Dem2 0 Dem_Both 0 defense 0 Strat_Riv 0 yrSalientNoMIDs_SA 16 yrSalientNoMIDs_SA_sq 256 yrSalientNoMIDs_SA_cb 4096
 relogitq 
 
  setx ServSat1 0 ServSat2 0 post2000 0 Dem1 0 Dem2 0 Dem_Both 0 defense 0 Strat_Riv 0 yrSalientNoMIDs_SA 16 yrSalientNoMIDs_SA_sq 256 yrSalientNoMIDs_SA_cb 4096
 relogitq, rr (Dem1 0 1 Dem2 0 1 Dem_Both 0 1)
 
 setx ServSat1 0 ServSat2 0 post2000 0 Dem1 0 Dem2 0 Dem_Both 0 defense 0 Strat_Riv 0 yrSalientNoMIDs_SA 16 yrSalientNoMIDs_SA_sq 256 yrSalientNoMIDs_SA_cb 4096
 relogitq, rr(Strat_Riv 0 1)
 
 
 
 
***************************************
* Replication for the Online Appendix * 
***************************************

** Table A1: Summary Statistics**
summ yrSalientMIDs_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA if PolRev==1


**Table A2: Correlation Matrix**
corr yrSalientMIDs_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA if PolRev==1

 
** Table A3: Replicate Table 1 with Firth's Logit Robustness Check**
eststo M5:  firthlogit  yrSalientMIDs_SA ServSat1 ServSat2 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000
eststo M6: firthlogit 	yrSalientMIDs_SA ServSat1 ServSat2  		lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000
eststo M7: firthlogit  yrSalientMIDs_SA ServSat1 ServSat2 post2000 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1  
eststo M8: firthlogit 	yrSalientMIDs_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1


esttab M5 M6 M7 M8, se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01)


** Table A4: Replicate Table 1 with Probit Robustness Check**
eststo M9:  probit   yrSalientMIDs_SA ServSat1 ServSat2 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000, robust
eststo M10: probit 	yrSalientMIDs_SA ServSat1 ServSat2  		lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000, robust
eststo M11: probit  yrSalientMIDs_SA ServSat1 ServSat2 post2000 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1, robust  
eststo M12: probit 	yrSalientMIDs_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1, robust


esttab M9 M10 M11 M12, se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01)


 **Table A5: Replicate Table 1 with Seemingly Unrelated Bivariate Probit for Satellite Possession**

eststo M13: biprobit (yrSalientMIDs_SA    ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both     defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb) (ServSat1  HigherEd1 lnGDP1 GDPxHE1  CivSpaceBureau1 Dem1 lowRR_cnt1 majpow1 NoServSat1 NoServSat1_sq NoServSat1_cb) if PolRev==1 , robust
eststo M14: biprobit (yrSalientMIDs_SA    ServSat1 ServSat2 post2000 lnmilex1 lnmilex2  lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both     defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb) (ServSat2  HigherEd2 lnGDP2 GDPxHE2 CivSpaceBureau2 Dem2 lowRR_cnt2 majpow2 NoServSat2 NoServSat2_sq NoServSat2_cb) if PolRev==1 , robust
esttab M13 M14, se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01) 


**Table A6: Replicate Table 1 with Multivariate Probit for Satellite Possession for Both Dyad Members**
eststo M14a: mvprobit (yrSalientMIDs_SA    ServSat1 ServSat2 post2000 lnmilex1 lnmilex2  lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both     defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb) (ServSat1  HigherEd1 lnGDP1 GDPxHE1  CivSpaceBureau1 Dem1 lowRR_cnt1 majpow1 NoServSat1 NoServSat1_sq NoServSat1_cb) (ServSat2  HigherEd2 lnGDP2 GDPxHE2 CivSpaceBureau2 Dem2 lowRR_cnt2 majpow2 NoServSat2 NoServSat2_sq NoServSat2_cb) if PolRev==1 , robust
esttab M14a, se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01) 

 
**Table A7: Sample of Satellite Countries Only**
eststo M15: relogit  yrSalientMIDs_SA ServSat1 ServSat2 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if SatelliteCountries==1 & year<=2000 &  PolRev==1
eststo M16: relogit 	yrSalientMIDs_SA ServSat1 ServSat2  		lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if SatelliteCountries==1 & year<=2000 &  PolRev==1
eststo M17: relogit  yrSalientMIDs_SA ServSat1 ServSat2 post2000 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if SatelliteCountries==1 &   PolRev==1
eststo M18: relogit 	yrSalientMIDs_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if SatelliteCountries==1 &  PolRev==1

esttab M15 M16 M17 M18, se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01) 


**Table A8: Replicate Table 1 without GDP Per Capita Variables**
eststo M19: relogit  yrSalientMIDs_SA ServSat1 ServSat2 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000
eststo M20: relogit 	yrSalientMIDs_SA ServSat1 ServSat2  		lnmilex1 lnmilex2  lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000
eststo M21: relogit  yrSalientMIDs_SA ServSat1 ServSat2 post2000 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1  
eststo M22: relogit 	yrSalientMIDs_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2  lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1
esttab M19 M20 M21 M22, se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01) 

** Table A9: Replicate Table 1 by replacing Military Spending with CINC Scores***  
eststo M23: relogit 	yrSalientMIDs_SA ServSat1 ServSat2  		cinc1 cinc2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000
eststo M24: relogit 	yrSalientMIDs_SA ServSat1 ServSat2 post2000 cinc1 cinc2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1
esttab M23 M24 , se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01)


** Table A10: Replicate Table 1 with including Contiguity and PowerShare*** CapShare1 directcontig
eststo M25: relogit 	yrSalientMIDs_SA ServSat1 ServSat2  		lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv CapShare1 directcontig yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000
eststo M26: relogit 	yrSalientMIDs_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv CapShare1 directcontig yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1
esttab M25 M26 , se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01)


**Table A11: Re-Estimating Table 1 Using Minor MIDs (Fatlevel 0-2)**
eststo M27: relogit  yrMinMIDS_SA ServSat1 ServSat2  yrMinNoMIDS_SA yrMinNoMIDS_SA_sq yrMinNoMIDS_SA_cb  if PolRev==1 & year<=2000
eststo M28: relogit 	yrMinMIDS_SA ServSat1 ServSat2  		lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrMinNoMIDS_SA yrMinNoMIDS_SA_sq yrMinNoMIDS_SA_cb  if PolRev==1 & year<=2000
eststo M29: relogit  yrMinMIDS_SA ServSat1 ServSat2 post2000 yrMinNoMIDS_SA yrMinNoMIDS_SA_sq yrMinNoMIDS_SA_cb if PolRev==1  
eststo M30: relogit  yrMinMIDS_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrMinNoMIDS_SA yrMinNoMIDS_SA_sq yrMinNoMIDS_SA_cb   if PolRev==1

esttab M27 M28 M29 M30, se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01) 


**Table A12: Re-Estimating Table 1 Using Lower Threshold MIDs (Fatlevel 2-6)**
eststo M31: relogit  yrSalientMIDs_SA2 ServSat1 ServSat2 yrSalientNoMIDs_SA2 yrSalientNoMIDs_SA2_sq yrSalientNoMIDs_SA2_cb if PolRev==1 & year<=2000
eststo M32: relogit 	yrSalientMIDs_SA2 ServSat1 ServSat2  		lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA2 yrSalientNoMIDs_SA2_sq yrSalientNoMIDs_SA2_cb if PolRev==1 & year<=2000
eststo M33: relogit  yrSalientMIDs_SA2 ServSat1 ServSat2 post2000 yrSalientNoMIDs_SA2 yrSalientNoMIDs_SA2_sq yrSalientNoMIDs_SA2_cb if PolRev==1  
eststo M34: relogit 	yrSalientMIDs_SA2 ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA2 yrSalientNoMIDs_SA2_sq yrSalientNoMIDs_SA2_cb if PolRev==1

esttab M31 M32 M33 M34, se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01) 


**Table A13: Replicates Table 1 Using Logit with Fixed Effects**
eststo M35: xtlogit  yrSalientMIDs_SA ServSat1 ServSat2 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000, fe
eststo M36: xtlogit yrSalientMIDs_SA ServSat1 ServSat2  		lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1 & year<=2000, fe
eststo M37: xtlogit  yrSalientMIDs_SA ServSat1 ServSat2 post2000 yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1, fe  
eststo M38: xtlogit 	yrSalientMIDs_SA ServSat1 ServSat2 post2000 lnmilex1 lnmilex2 lnrgdppc1 lnrgdppc2 lndist Dem1 Dem2 Dem_Both defense Strat_Riv yrSalientNoMIDs_SA yrSalientNoMIDs_SA_sq yrSalientNoMIDs_SA_cb if PolRev==1, fe


esttab M35 M36 M37 M38, se(2) pr2 b(2) star(* 0.10 ** 0.05 *** 0.01) 
